package com.dhsc.service.impl.khzne;

import com.dhsc.domain.ywzx.khzne.DqskhtgVo;
import com.dhsc.domain.yypt.LayuiTableVo;
import com.dhsc.exception.MyException;
import com.dhsc.local.dao.ywzj.khzne.IDqstgkhDao;
import com.dhsc.service.khzne.IDqstgkhService;
import com.dhsc.util.CommonUtil;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 多券商托管客户
 * @date 2024/11/11 16:45
 */
@Service
@Slf4j
public class DqstgkhServiceImpl implements IDqstgkhService {

    @Autowired
    private IDqstgkhDao dqstgkhDao;
    @Override
    public LayuiTableVo queryDqstgkhinfo(DqskhtgVo d) {
        LayuiTableVo obj = new LayuiTableVo();
        try {
            if(!CommonUtil.isNotEmptyObj(d.getState())){
                PageMethod.startPage(d.getPage(), d.getLimit());
            }
            List<DqskhtgVo> list = dqstgkhDao.queryDqstgkhinfo(d);
            PageInfo<DqskhtgVo> pageInfo = new PageInfo<>(list);
            obj.setData(list);
            obj.setMsg("");
            obj.setCount(pageInfo.getTotal());
            obj.setCode(0);
        }catch (Exception e){
            log.error("查询多券商托管客户信息出错",e);
            throw new MyException("查询多券商托管客户信息出错",e);
        }
        return obj;
    }
}
